package com.example.demo.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @author songjun
 * @date 2020/12/24
 */
@Configuration
public class RestTemplateConfig {
    @Bean
    @ConditionalOnMissingBean(RestTemplate.class)
    public RestTemplate restTemplate(){
        RestTemplate restTemplate = new RestTemplate();
//        HttpComponentsClientHttpRequestFactory httpComponentsClientHttpRequestFactory
//                = new HttpComponentsClientHttpRequestFactory();
//        httpComponentsClientHttpRequestFactory.setConnectTimeout(20000);
//        httpComponentsClientHttpRequestFactory.setReadTimeout(20000);
//
//        restTemplate.setRequestFactory(httpComponentsClientHttpRequestFactory);
        return restTemplate;
    }

}
